package com.java.polymorphism.exer_2;

/**
 * @author luzhikun
 * @date 2020/12/6- 16:58
 */
public class Test {
    public static void main(String[] args) {
        Person person = new Student1();
        person.setAge(22);
        person.setName("小花");
        if (person instanceof Student1) {
            Student1 student1 = (Student1) person;
            student1.study();
        }
        System.out.println("名字是：" + person.getName() + "  年龄是：" + person.getAge());
        Person person1 = new Tercher2();
        person1.setAge(58);
        person1.setName("骗子");
        if (person1 instanceof Tercher2) {
            Tercher2 tercher2 = (Tercher2) person1;
            tercher2.teach();
        }
        System.out.print("名字是：" + person1.getName() + "  年龄是：" + person1.getAge());
    }
}
